/***********************************************************
 * Author: 	Brandon McKune
 * E-Mail:	bmckune.cs@gmail.com
 * Date:	September 2, 2011
 * Class:	Advanced OS
 * Time:	1150 - 1325
 * Smstr:	Fall 2011
 */
#include "ClRTClock.h"

ClRTClock* ClRTClock::m_ptrClRTClock = NULL;

/**
 * 	ClRTClock Default Constructor:
 * 	Description:
 * 		This initializes the ClRTClock object.  This is private
 * 		due to the ClRTClock being a singleton object.
 * 	Parameters:
 * 		N/A
 * 	Return:
 * 		N/A
 */
ClRTClock::ClRTClock(){
	this->m_uint64ClockTicks = 0;
}

/**
 * 	ClRTClock Destructor:
 * 	Description:
 * 		This function deletes the privately contained object
 * 		of itself.
 * 	Parameters:
 * 		N/A
 * 	Return:
 * 		N/A
 */
ClRTClock::~ClRTClock(){
	//no dynamically created memory
	delete(m_ptrClRTClock);
}

/**
 * 	getInstance Function:
 * 	Description:
 * 		This function creates a ClRTClock object on the first
 * 		call to getInstance().  If the object is already created,
 * 		then it returns a pointer to that object.
 * 	Parameters:
 * 		N/A
 * 	Return:
 * 		ClRTClock* ptr
 * 			Pointer to the ClRTClock object.
 */
ClRTClock* ClRTClock::getInstance(){
	if(m_ptrClRTClock == NULL){
		m_ptrClRTClock = new ClRTClock();
	}

	return m_ptrClRTClock;
}

/**
 * 	getTimeInterval Function:
 * 	Description:
 * 		This function returns the current time in Clock ticks.
 * 		The value of a clock tick is stored within the includes.h
 * 		file.  This represents the scheduling interval number and
 * 		is used to simulate a clock.
 * 	Parameters:
 * 		N/A
 * 	Return:
 * 		uint64_t tick
 * 			This represents the scheduling interval value that
 * 			the algorithm is currently on.  This is base 10 value
 * 			and starts at 0 no matter the system time.
 */
uint64_t ClRTClock::getTimeInterval(){
	return this->m_uint64ClockTicks;
}

/*
 * 	tick Function:
 * 	Description:
 * 		The tick function is not thread safe, and increments the
 * 		clock value by 1.  This represents a schedule interval that
 * 		is simulated in ns according to whatever the schedule interval
 * 		is in includes.h
 * 	Parameters:
 * 		N/A
 * 	Return:
 * 		void
 */
void ClRTClock::tick(){
	this->m_uint64ClockTicks++;
}
